<extend name="desktop_default/template/user/base_user" />
<block name="area_header">
    <link rel="stylesheet" href="__CSS__/user/order_detail/style.css">
</block>

<block name="area_top">

</block>
<block name="user_top">

</block>
<block name="main_content">
    <div class="order">
        <div class="user-tab">
            <a class="selected default" href="javascript:void(0);">订单详情</a>
        </div>
        <div class="progressbar">
            <eq name="detail.status_ss" value="3">
                <img src="__IMG__/user/order_detail/2shouhuo.png">
            </eq>
            <eq name="detail.status_ss" value="6">
                <img src="__IMG__/user/order_detail/2pingjia.png">
            </eq>
        </div>
        <div class="order-status">
            <h4>当前订单状态：{$detail.status_desc}<neq name="detail.status_ss" value="2">，请查看页面下方物流信息了解宝贝的寄送情况</neq></h4>
            <eq name="detail.status_ss" value="3">
                <p>您还有 <span id="count_down">0天0小时0分0秒</span> 来完成此订单的 "确认收货" 操作</p>
                <p>如果期间您没有 "确认收货"，也没有 "申请退款" 以下订单将自动确认收货</p>
                <p>1.点这里<a class="btn confirm" href="javascript:void(0);" data-code="{$detail.order_code}">确认收货</a></p>
            </eq>
            <eq name="detail.status_ss" value="6">
                <p>您还有 <span id="count_down">0天0小时0分0秒</span> 来完成此订单的 "评价" 操作</p>
                <p>如果期间您没有 "评价"，以下订单将自动评价</p>
                <p>1.点这里<a class="btn pingjia" href="{:U('mengwu/user/order_pingjia',array('order_code'=>$detail['order_code']))}">评价</a></p>
            </eq>
            <notempty name="express_info">
                <h4 class="logistics">物流信息</h4>
                <p>物流公司：{$express_info.expressname}</p>
                <p>快递单号：{$express_info.expressno}</p>
                <p>物流跟踪：暂无</p>
            </notempty>

        </div>
        <div class="user-tab">
            <a class="selected default" href="javascript:void(0);">订单信息</a>
        </div>
        <div class="order-detail">
            <div class="detail-info">
                <p><span>收货地址：</span>{$detail.contactname}, 联系电话：{$detail.mobile}, 地址：{$detail.province} {$detail.city} {$detail.area} {$detail.detailinfo}, 邮编：{$detail.postal_code}</p>
                <p><span>买家留言：</span>{$detail.note|default="无"}</p>
            </div>
            <div class="head">
                <div class="ch sp">商品</div>
                <div class="ch price">单价</div>
                <div class="ch count">数量</div>
                <div class="ch state">交易状态</div>
                <div class="ch total">商品总价（元）</div>
            </div>
            <include file="desktop_default/template/user/order_detail" />
        </div>

    </div>

</block>
<block name="area_footer">
<eq name="detail.status_ss" value="3">
    <script type="text/javascript">
        var confirm = antd.Modal.confirm;
        var message = antd.message;
        $('.btn.confirm').click(function(){
            var code = $(this).attr('data-code');
            confirm({
                title: '您是否要确认收货？',
                content: '',
                onOk:function() {
                    var hide = message.loading('正在执行中...',0);
                    var url = document.getElementsByTagName('base')[0].href + '/mengwu/mengwuApi/order_sure';
                    let data = {
                        order_code: code
                    };
                    _post(url,jQuery.param(data), {
                        //处理返回数据
                        data_back: function(data){
                            hide();
                            setTimeout(function(){
                                if(data.status){
                                    message.success('操作成功！');
                                    setTimeout(function(){window.location.reload()},500);
                                }else{
                                    message.error('操作失败！');
                                }
                            },500);

                        }
                    });
                },
                onCancel:function() {}
            });
        });
    </script>
</eq>

<in name="detail.status_ss" value="3,6">
    <script type="text/javascript">

        var interval = 1000;
        function ShowCountDown(endtime,divname,_t){
            var endDate = new Date(endtime);
            var now = new Date();
            var cc = document.getElementById(divname);
            if(endDate<=now){
                cc.innerHTML = "0天0小时0分0秒";
                clearInterval(_t);
                return;
            }
            var leftTime=endDate.getTime()-now.getTime();
            var leftsecond = parseInt(leftTime/1000);
            var day1=Math.floor(leftsecond/(60*60*24));
            var hour=Math.floor((leftsecond-day1*24*60*60)/3600);
            var minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
            var second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
            cc.innerHTML = day1+"天"+hour+"小时"+minute+"分"+second+"秒";
        }

        var count_down_time = {$count_down_time}*1000;
        ShowCountDown(count_down_time,'count_down');
        var t = setInterval(function(){ShowCountDown(count_down_time,'count_down',t);}, interval);

    </script>
</in>
</block>
